import { IMG_PATH } from '../../../../config/index.js'
import { ApiRootUrl } from '../../../../config/index.js'
import Toast from '../../../../@vant/weapp/toast/toast';
import Dialog from '../../../../@vant/weapp/dialog/dialog';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    IMG_PATH:IMG_PATH,
    dataList:[]
  },
  backClick() {
    wx.navigateBack();
  },
  namelongTab(event){
    console.log(event);
    Toast(event.currentTarget.dataset.text);
  },
  queryList(){
    Toast.loading({
      duration: 0,
      message: '加载中...',
      forbidClick: true,
    });
    let self = this;
    wx.request({
      url: `${ApiRootUrl}/hire/selectJobs`,
      method: 'get',
      header: {
        'content-type': 'application/json; charset=utf-8',
        'cookie': wx.getStorageSync("sessionid")
      },
      success(res) {
        Toast.clear();
        if(res.data.code == 20000){
          self.setData({
            dataList:res.data.data
          })
        }else{
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: res.data.message,
          });
        }
      },
      fail(res){
        Toast.clear();
        Toast({
          duration: 3000,
          forbidClick: true,
          type: 'fail',
          message: '网络已断开',
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.queryList();
  },
  zhaopinClick(event){
    console.log(event);
    let obj = event.currentTarget.dataset.obj;
    wx.navigateTo({
      url: `../details/details?id=${obj.id}`,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})